//
//  DMInfoManage.m
//  DMGME
//
//  Created by ihope99 on 15/8/31.
//  Copyright (c) 2015年 GYP. All rights reserved.
//

#import "DMInfoManageController.h"
#import "DMInfoViewController.h"
#import "DMChatViewController.h"

@interface DMInfoManageController ()

@end

@implementation DMInfoManageController

- (void)viewDidLoad {
    [super viewDidLoad];
    DMChatViewController *chat = [[DMChatViewController alloc] initWithDisplayConversationTypes:@[@(ConversationType_PRIVATE),@(ConversationType_DISCUSSION), @(ConversationType_APPSERVICE), @(ConversationType_PUBLICSERVICE),@(ConversationType_GROUP),@(ConversationType_SYSTEM)] collectionConversationType:@[@(ConversationType_GROUP),@(ConversationType_DISCUSSION)]];
    [self addChildViewController:chat];
    
    DMInfoViewController *info = [[DMInfoViewController alloc] init];
    [self addChildViewController:info];

    
    NSArray *buttonNames = [NSArray arrayWithObjects:@"消息", @"通知", nil];
    UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:buttonNames];
    segmentedControl.frame = CGRectMake(KWidth/2-45, 10, 90, 30);
    segmentedControl.selectedSegmentIndex=0;
    segmentedControl.layer.masksToBounds = YES;
    segmentedControl.layer.cornerRadius = 2;
    
    DMChatViewController *chat1 = self.childViewControllers[0];
    chat.view.frame = self.view.bounds;
    [self.view addSubview:chat1.view];

    //添加事件
    
    [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    self.navigationItem.titleView = segmentedControl;
    [self AddLeftImageBtn:[UIImage imageNamed:@"fanhui_03 2"]target:self action:@selector(GoBack)];

    
  }
-(void)segmentAction:(UISegmentedControl *)Seg{
//    NSInteger Index = Seg.selectedSegmentIndex;
//    NSLog(@"Seg.selectedSegmentIndex:%ld",(long)Index);
    if (Seg.selectedSegmentIndex == 0) {
        
        DMChatViewController *chat = self.childViewControllers[0];
        chat.view.frame = self.view.bounds;
        [self.view addSubview:chat.view];
        
        
    }else
    {
        DMInfoViewController *chat = self.childViewControllers[1];
        chat.view.frame = self.view.bounds;
        [self.view addSubview:chat.view];

    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
